<template>
	<view class="my-msg">
		<navbar ref="navbar" backColor="#000" :config="config"></navbar>
		<view class="middle">
			<view class="item" @click="goTodel(0, '活动消息')">
				<view class="left">
					<text class="iconfont">&#xe652;</text>
					<text class="count"
						v-if="titleOne.num == 0 ? false : titleOne.num">{{ titleOne.num }}</text>
					<!-- <image src="https://zhongyi-shop.oss-cn-beijing.aliyuncs.com/songhe/weixin/static/alipay.png" mode=""></image> -->
				</view>
				<view class="right">
					<view class="msg">
						<view class="name">
							活动消息
							
							<!-- <text >{{msg[0] && msg[0].num? msg[0].num : ''}}</text> -->
						</view>
						<view class="time">{{ titleOne.time ? titleOne.time : '' }}</view>
					</view>
					<view class="advertisement u-display1" style="color: #474747;">
						{{ titleOne.remark ? titleOne.remark : '' }}</view>
				</view>
			</view>
			<view class="item" @click="goTodel(1, '支付消息')">
				<view class="left">
					<text class="iconfont">&#xe641;</text>
					<text class="count" v-if="titleTwo == 0 ? false : titleTwo.num">{{ titleTwo.num }}</text>
					<!-- <image src="https://zhongyi-shop.oss-cn-beijing.aliyuncs.com/songhe/weixin/static/alipay.png" mode=""></image> -->
				</view>
				<view class="right right2">
					<view class="msg">
						<view class="name">
							支付消息
							
						</view>
						<view class="time">{{ titleTwo.time ? titleTwo.time : '' }}</view>
					</view>
					<view class="advertisement u-display1">{{ titleTwo.remark ? titleTwo.remark : '' }}</view>
				</view>
			</view>
			<view class="item" @click="goTodel(2, '物流消息')">
				<view class="left right3">
					<text class="iconfont">&#xe691;</text>
					<text class="count"
						v-if="titleThree.num == 0 ? false : titleThree.num">{{ titleThree.num }}</text>
					<!-- <image src="https://zhongyi-shop.oss-cn-beijing.aliyuncs.com/songhe/weixin/static/alipay.png" mode=""></image> -->
				</view>
				<view class="right right4">
					<view class="msg">
						<view class="name">
							物流消息
							
						</view>
						<view class="time">{{ titleThree.time ? titleThree.time : '' }}</view>
					</view>
					<view class="advertisement u-display1">{{ titleThree.remark ? titleThree.remark : '' }}</view>
				</view>
			</view>
			<view class="item" @click="goTodel(3, '售后消息')">
				<view class="left">
					<text class="iconfont">&#xf132;</text>
					<text class="count" v-if="titleFour == 0 ? false : titleFour.num">{{ titleFour.num }}</text>
					<!-- <image src="https://zhongyi-shop.oss-cn-beijing.aliyuncs.com/songhe/weixin/static/alipay.png" mode=""></image> -->
				</view>
				<view class="right right5">
					<view class="msg">
						<view class="name">
							售后消息
							
						</view>
						<view class="time">{{ titleFour.time ? titleFour.time : '' }}</view>
					</view>
					<view class="advertisement u-display1">{{ titleFour.remark ? titleFour.remark : '' }}</view>
				</view>
			</view>
			<view class="item" @click="goTodel(4, '互动消息')">
				<view class="left"><text class="iconfont">&#xe6f9;</text>
				<text v-if="titleFive == 0 ? false : titleFive.num">{{ titleFive.num }}</text>
				</view>
				<view class="right">
					<view class="msg">
						<view class="name">
							互动消息
							
						</view>
						<view class="time">{{ titleFive.time ? titleFive.time : '' }}</view>
					</view>
					<view class="advertisement u-display1">{{ titleFive.remark ? titleFive.remark : '' }}</view>
				</view>
			</view>
			<view class="item" @click="goTodel(5, '系统消息')">
				<view class="left">
					<text class="iconfont">&#xf132;</text>
					<text class="count" v-if="titleSix == 0 ? false : titleSix.num">{{ titleSix.num }}</text>
					<!-- <image src="https://zhongyi-shop.oss-cn-beijing.aliyuncs.com/songhe/weixin/static/alipay.png" mode=""></image> -->
				</view>
				<view class="right right5">
					<view class="msg">
						<view class="name">
							系统消息
							
						</view>
						<view class="time">{{ titleSix.time ? titleSix.time : '' }}</view>
					</view>
					<view class="advertisement u-display1">{{ titleSix.remark ? titleSix.remark : '' }}</view>
				</view>
			</view>
		</view>
	</view>
	</view>
</template>

<script>
	import {
		unreadInfo
	} from '@/api/userInfo.js';
	export default {
		data() {
			return {
				config: {
					back: true, //false是tolbar页面 是则不写
					title: '消息',
					color: '#000',
					//背景颜色;参数一：透明度（0-1）;参数二：背景颜色（array则为线性渐变，string为单色背景）
					backgroundColor: [1, "#fff"],
					statusBarFontColor: '#1A1A1A',
					backIconColor: "#000",
				},
				msg: [], //获取的msg
				title: [],
				titleOne: {},
				titleTwo: {},
				titleThree: {},
				titleFour: {},
				titleFive: {},
				titleSix: {}
			};
		},
		onShow() {
			this.getMsg();
		},

		methods: {
			//跳转消息中心
			goTodel(type, name) {
				uni.navigateTo({
					url: './eventDetails?type=' + type + '&name=' + name
				});
			},

			//获取消息
			getMsg() {
				this.$http.get(unreadInfo).then(res => {
					if (res && res.code == 200) {
						console.log(res);
						this.msg = res.list;
						this.titleOne = this.msg[0];
						this.titleTwo = this.msg[1];
						this.titleThree = this.msg[2];
						this.titleFour = this.msg[3];
						this.titleFive = this.msg[4];
						this.titleSix = this.msg[5];
						// this.addNum=this.msg[0]+this.msg[1]+this.msg[2]+this.msg[3]+this.msg[4]+this.msg[5]

						// this.msg.forEach(function(v){
						// 	// console.log("type",v.type)
						// 	let newMsg = v.type
						// 	console.log(newMsg,11111)
						// })
					}
				});
			}
		}
	};
</script>

<style scoped lang="scss">
	.middle {
		width: 100%;
		padding:0 31rpx;
		box-sizing: border-box;
		.item {
			display: flex;
			align-items: center;
			background-color: #FFFFFF;
			height: 131rpx;
			// border-bottom: 1rpx solid #e6e6e6;
			.left {
				margin-right: 19rpx;
				width: 85rpx;
				height: 85rpx;
				border-radius: 50%;
				display: flex;
				align-items: center;
				justify-content: center;
				color: #fff;
				position: relative;

				.iconfont {
					font-size: 48rpx;
				}

				image {
					width: 90rpx;
					height: 90rpx;
					border-radius: 50%;
				}
			}

			.left2 {
				background: #ad9be5;
			}

			.left3 {
				background: #4ed47f;
			}

			.left4 {
				background: #e4c78d;
			}

			.left5 {
				background: #fe9168;
			}

			.right {
				flex: 1;
				display: flex;
				flex-direction: column;
				justify-content: space-around;

				.msg {
					display: flex;
					justify-content: space-between;
					align-items: flex-start;
					color: #474747;

					.name {
						font-weight: bold;
						font-size: 27rpx;
						color: #333333;
						line-height: 27rpx;

						text {
							margin-left: 10rpx;
							color: #ffffff;
							font-size: 20rpx;
							font-weight: 400;
							padding: 0 6rpx;
							background-color: #ff0000;
							border-radius: 13rpx;
						}
					}

					.time {
						font-weight: 400;
						font-size: 23rpx;
						color: #999999;
						line-height: 23rpx;
					}
				}

				.advertisement {
					font-weight: 400;
					font-size: 23rpx;
					color: #999999;
					line-height: 23rpx;
					margin-top: 19rpx;
					
					
				}
			}
		}

		.item:nth-child(odd) .left {
			background-color: #FF211F;
		}

		.item:nth-child(even) .left {
			background-color: rgb(46, 208, 135);
		}
	}

	.count {
		padding: 0px 11rpx !important;
		border-radius: 100rpx !important;
		width: 31rpx;
		height: 31rpx;
		background: #FF211F;
		border-radius: 96rpx 96rpx 96rpx 96rpx;
		border: 2rpx solid #FFFFFF;
		position: absolute;
		top:0;
		right: 0;
		display: flex;
		flex-direction: row;
		justify-content: center;
		align-items: center;
		
	}
	page{
		background-color: #fff;
	}
	.my-msg{
		width: 100%;
		height: auto;
		background-color: #fff;
		
	}
</style>